package org.azj.fieldTypeConverter;

import java.util.Date;


public class DateConverter  implements ITypeConverter{
	@Override
	public String Convert(Object originValue, String column) throws TypeParseException
	{
		// date should be regarded as String before inserting into table
		String startDate = originValue.toString();
		String parttern="yyyy-MM-dd";
		Date tmpDate;
		try {
			tmpDate = java.sql.Date.valueOf(startDate);	
		} catch (Exception e) {
			throw new TypeParseException(
					"日期格式转换出现错误，期望的样式[" + parttern + "]，"
					+ "实际的样式[" + startDate + "], 正在处理的列是[" + column + "]");
		}
		
		return "'" + tmpDate.toString() + "'";
	}
}
